Ext.ns('App');
App = {
	init : function() {
		Ext.QuickTips.init();
		//面板控制工具(生成东、西、中三个面板，以及对这三个面板的管理)
		this.propertyManager = new App.property.PropertyManager();

		//创建工作区域面板
		var viewport = new Ext.Viewport({
					layout : 'border',
					items : [this.createNorth(), this.createWest(), this.createEast(), this.createCenter()]
				});
		//初始画板区域
		this.initEditor();
	},

	initEditor : function() {
		var xml = "<?xml version='1.0' encoding='UTF-8'?>" +"<process xmlns='http://jbpm.org/4.4/jpdl'>" + "<start g='77,118,48,48' name='start 1'>" + "<transition to='fork 1'/>" + "</start>" + "<auto g='341,49,90,50' name='auto 1'>" + "<transition to='join 1'/>" + "</auto>" + "<auto g='338,135,90,50' name='auto 2'>" + "<transition to='join 1'/>" + "</auto>" + "<auto g='330,221,90,50' name='auto 3'>" + "<transition to='join 1'/>" + "</auto>" + "<auto g='625,138,90,50' name='auto 4'>" + " <transition to='end 1'/>" + "</auto>" + "<end g='738,139,48,48' name='end 1'/>" + "<fork g='213,117,48,48' name='fork 1'>" + "<transition to='auto 1'/>" + "<transition name='to auto 2' to='auto 2'/>" + "<transition name='to auto 3' to='auto 3'/>" + "</fork>" + "<join g='514,133,48,48' name='join 1'>"
				+ "<transition to='auto 4'/>" + "</join>" + "</process>"
		//创建编辑器
		var editor = new Gef.jbs.ExtEditor();
		//流程定义解读器
		var input = new Gef.jbs.JBSEditorInput();
		input.readXml(xml);

		var workbenchWindow = new Gef.ui.support.DefaultWorkbenchWindow();
		workbenchWindow.getActivePage().openEditor(editor, input);

		workbenchWindow.render();
		Gef.activeEditor = editor;

		this.propertyManager.initSelectionListener(editor);
	},

	//创建北面导航面板
	createNorth : function() {
		var p = new Ext.Panel({
					region : 'north',
					html : '<h1 id="pageh1">Web工作流设计器  JSflow - 华东凯亚<h1>'
				});

		App.northPanel = p;
		return p;
	},
	//创建西面导航面板
	createWest : function() {
		var p = this.propertyManager.getLeft();
		return p;
	},
	//创建东面导航面板
	createEast : function() {
		var p = new App.PalettePanel({
					collapsible : true
				});

		App.eastPanel = p;
		return p;
	},
	//创建中间导航面板
	createCenter : function() {
		var p = new App.CanvasPanel();

		App.centerPanel = p;
		return p;
	}
};
Ext.onReady(App.init, App);
